package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BdCustclass;
import com.ruoyi.system.service.IBdCustclassService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 客户基本分类Controller
 * 
 * @author ruoyi
 * @date 2025-09-08
 */
@Controller
@RequestMapping("/system/custclass")
public class BdCustclassController extends BaseController
{
    private String prefix = "system/custclass";

    @Autowired
    private IBdCustclassService bdCustclassService;

    @RequiresPermissions("system:custclass:view")
    @GetMapping()
    public String custclass()
    {
        return prefix + "/custclass";
    }

    /**
     * 查询客户基本分类列表
     */
    @RequiresPermissions("system:custclass:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BdCustclass bdCustclass)
    {
        startPage();
        List<BdCustclass> list = bdCustclassService.selectBdCustclassList(bdCustclass);
        return getDataTable(list);
    }

    /**
     * 导出客户基本分类列表
     */
    @RequiresPermissions("system:custclass:export")
    @Log(title = "客户基本分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BdCustclass bdCustclass)
    {
        List<BdCustclass> list = bdCustclassService.selectBdCustclassList(bdCustclass);
        ExcelUtil<BdCustclass> util = new ExcelUtil<BdCustclass>(BdCustclass.class);
        return util.exportExcel(list, "客户基本分类数据");
    }

    /**
     * 新增客户基本分类
     */
    @RequiresPermissions("system:custclass:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存客户基本分类
     */
    @RequiresPermissions("system:custclass:add")
    @Log(title = "客户基本分类", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BdCustclass bdCustclass)
    {
        return toAjax(bdCustclassService.insertBdCustclass(bdCustclass));
    }

    /**
     * 修改客户基本分类
     */
    @RequiresPermissions("system:custclass:edit")
    @GetMapping("/edit/{pkCustclass}")
    public String edit(@PathVariable("pkCustclass") String pkCustclass, ModelMap mmap)
    {
        BdCustclass bdCustclass = bdCustclassService.selectBdCustclassByPkCustclass(pkCustclass);
        mmap.put("bdCustclass", bdCustclass);
        return prefix + "/edit";
    }

    /**
     * 修改保存客户基本分类
     */
    @RequiresPermissions("system:custclass:edit")
    @Log(title = "客户基本分类", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BdCustclass bdCustclass)
    {
        return toAjax(bdCustclassService.updateBdCustclass(bdCustclass));
    }

    /**
     * 删除客户基本分类
     */
    @RequiresPermissions("system:custclass:remove")
    @Log(title = "客户基本分类", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(bdCustclassService.deleteBdCustclassByPkCustclasss(ids));
    }
}
